#ifndef FACILITY_MANAGER_H
#define FACILITY_MANAGER_H

#ifndef FACILITY_H
#include "Facility.h"
#endif

#ifndef BASE_BELT_H
#include "Belt/base_belt.h"
#endif

#ifndef HUB_H
#include "Hub.h"
#endif

#ifndef CUTTER_H
#include "Cutter/cutter_define.h"
#endif

#ifndef FACILITYDEFINE_H
#include "Facility_Define.h"
#endif

#include <QSettings>

class Facility_Manager{
    friend class GameLogic;
    friend class My_Mouse;
    friend class Game_Scene;
    static const QString db_f_progress;           // 存档的位置
    static const int max_miner_progress;         // max开采的升级进度
    static const int max_transport_progress;    // max运输的升级进度
    static const int max_cutter_progress;        // max裁剪的升级进度
protected:
    Cargo_Manager * cargo_manager = null;

    std::unordered_map<std::string,FacilityDefine*> facility_define_map;
    Hub* hub = null;
    std::unordered_set<Base_Belt*> belt_facility;
    std::unordered_set<Facility*> other_facility;

    int miner_progress = 0;         //开采的升级进度
    int transport_progress = 0;    // 运输的升级进度
    int cutter_progress = 0;        // 裁剪的升级进度

    std::vector<double> miner_speed= { // 开采器的速度
        6.0,10.0,15.0,18.0
    };

    std::vector<double> transport_speed = { // 有关传输的速度
        6.0,10.0,15.0,18.0
    };

    std::vector<double> cutter_speed = { // 有关裁剪的速度
        6.0,10.0,15.0,18.0
    };

    void connetTwoFacility(Facility * f_in, int in_idx, Facility * f_out, int out_idx); // f_in 入口设备；f_out 出口设备
    void connnetFacilitys(Facility * f, std::unordered_set<Facility *>& fs);
    Facility * generateFacilityWithTypeAndIdx(FacilityType f_type, int groupIdx,  FacilityDirection direction, Coordinate coordinate);
    void deleteFacility(Facility *);



public:

    Facility_Manager(Cargo_Manager *cargo_manager);
    void update();
    void upgrate(int idx);
    void load_progress();
    // void setup_define(); // 根据信息 建立定义类 并加入 facility_define_map
    void do_save();
    void load_save();
    virtual ~Facility_Manager();
    void updateMinerTarget(Facility* miner,char t);
};

#endif // FACILITY_MANAGER_H
